package udp;

import java.io.IOException;
import java.net.*;

public class Send {
    public static void main(String[] args) throws IOException {
        //创建DatagramSocket对象，不指定端口号就随机绑定端口号
        DatagramSocket socket = new DatagramSocket(8888);
        //创建DatagramPacket对象
        String msg = "翻开回忆角落";
        byte[] bytes = msg.getBytes();
        DatagramPacket packet = new DatagramPacket(bytes,bytes.length,
                InetAddress.getByName("10.85.167.228"),9999);
        //发送数据
        socket.send(packet);
        //释放资源
        socket.close();
    }
}
